package com.zjcode.cdcer.controller;

import com.chinatechstar.component.commons.controller.BaseController;
import com.chinatechstar.component.commons.result.ListResult;
import com.chinatechstar.component.commons.result.ResultBuilder;
import com.chinatechstar.component.commons.supports.PageData;
import com.zjcode.cdcer.model.ZjcodeSelfTestInfo;
import com.zjcode.cdcer.model.basic.JsonObj;
import com.zjcode.cdcer.service.ZjcodeSelfTestInfoService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @createTime: 2023-09-15
 * @功能：风险因素表
 * @creater: yong
 */
@RestController
@Slf4j
@RequestMapping("/v1/riskfactor/")
public class TkmCerRiskFactorController extends BaseController {
    @Autowired
    private ZjcodeSelfTestInfoService zjcodeSelfTestInfoService;
    @PostMapping("listAllData")
    @ApiOperation("获取所有的风险因素表数据")
    public ListResult<Object> listAllData(@RequestBody PageData pageData) {
        return ResultBuilder.buildListSuccess(zjcodeSelfTestInfoService.listAllData(pageData));
    }
    @PostMapping("getContentById")
    @ApiOperation("获取风险因素表原始数据")
    public JsonObj getContentById(@RequestBody PageData pageData) {
        String id = (String) pageData.get("id");
        ZjcodeSelfTestInfo data1 = zjcodeSelfTestInfoService.queryById(id);
        HashMap<String, Object> data = new HashMap<>();
        data.put("id", data1.getId());
        data.put("content",data1.getContent());
        return JsonObj.success(data);
    }
}
